<template>
	<my-modal ref="service_modal" height="200" class="pad20" title="Customer Service" :showCancel='false'
		:asyncClose='false'>
		<view class="pad20" v-if="info">
			<view class="flex marv20">
				<u-icon name="kefu-ermai" class="marh20"></u-icon>
				<view>{{info.KEFU_NAME}}</view>
			</view>
			<view class="flex marv20" @click="$call(info.KEFU_TEL)">
				<u-icon name="phone" class="marh20"></u-icon>
				<view>{{info.KEFU_TEL}}</view>
			</view>
			<view class="flex marv20" v-if="info.KEFU_TEL2" @click="$call(info.KEFU_TEL2)">
				<u-icon name="phone" class="marh20"></u-icon>
				<view>{{info.KEFU_TEL2}}</view>
			</view>
		</view>
	</my-modal>
</template>

<script>
	import { getDictModule } from '@/service/common'
	export default {
		name: "service-modal",
		methods: {
			show() {
				this.$refs.service_modal.show();
			},
			hide() {
				this.$refs.service_modal.hide();
			},
			async getKeFuDict() {
				let { success, data } = await getDictModule("MODULE_KEFU")
				if (!success) return this.$msg("customer service is not online")
				this.info = data.map(r => ({
					[r.code]: r.value
				})).reduce((o, r) => Object.assign(o, r), {})
			}
		},
		data() {
			return {
				info: null
			}
		},
		created() {
			this.getKeFuDict()
		},
	};
</script>

<style lang="scss" scoped></style>
